<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStatisticLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('statistic_logs', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('自增ID');

            $table->unsignedTinyInteger('type')->default(0)->comment('类型: 1、非遗 2、文化信息 3、新闻资讯 4、文化之声 5、点播艺课');

            $table->unsignedBigInteger('res_id')->comment('关联相关id')->index();
            $table->unsignedBigInteger('user_id')->default(0)->comment('操作人id, 未登录为0')->index();
            $table->ipAddress('user_ip')->comment('ip地址');
            $table->string('click_date', 100)->comment('点击日期');
            $table->unsignedInteger('click_num')->comment('点击次数');

            $table->timestamps();
            $table->softDeletes();

            $table->engine = 'InnoDB';

        });
        DB::statement("alter table `statistic_logs` comment'统计日志表'");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('statistic_logs');
    }
}
